/**
 * Copyright (c) 2017-2022 Rushang Co.Ltd All Rights Reserved.
 */
package com.rshang.rsdp.controller;

import java.util.HashMap;
import java.util.List;

import com.rshang.rsdp.entity.DmRsdlGsb;
import com.rshang.rsdp.service.*;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rshang.rsdp.entity.DmRsdlGsa;
import com.rshang.rsdp.entity.TbDictory;
import com.rshang.rsdp.entity.TbRole;

/**
 * 功能简介：代码api<br/>
 *
 * @author zhangjun
 * @create 2017年8月14日上午10:51:40
 */
@Controller
@RequiresAuthentication
@RequestMapping("/dm")
public class DmController extends BaseController {

    @Autowired
    ITbRoleService roleService;

    @Autowired
    ITbDictoryService dicService;

    @Autowired
    IDmRsdlGsaService gsService;

    @Autowired
    IDmRsdlGsbService xgsService;

    @Autowired
    ITbRsdlRyxxService ryService;

    @Autowired
    IDmRsdlZhxxService zhService;

    @Autowired
    ITbUserService userService;


    @RequestMapping("/systemRole")
    @ResponseBody
    public List<TbRole> getSystemRole() {
        return roleService.getSystemRole();
    }

    @RequestMapping("/dicFl")
    @ResponseBody
    public List<TbDictory> getDmfl() {
        return dicService.getDmFl();
    }

    @RequestMapping("/zhlx")
    @ResponseBody
    public List<TbDictory> getZhlx() {
        return dicService.getDicByFl("账户类型");
    }

    @RequestMapping("/gs")
    @ResponseBody
    public List<DmRsdlGsa> getGs() {
        return gsService.getYxGs();
    }

    @RequestMapping("/xgs")
    @ResponseBody
    public List<DmRsdlGsb> getYxXgsByGs() {
        return xgsService.getYxXgsByGs(request);
    }

    @RequestMapping("/cxgs")
    @ResponseBody
    public List<DmRsdlGsa> getCxGs() {
        return gsService.getCxGs();
    }

    @RequestMapping("/czrgs")
    @ResponseBody
    public List<HashMap> getCxGsByCzr() {
        return gsService.getGsByCzr(this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId());
    }

    @RequestMapping("/czrxgs")
    @ResponseBody
    public List<HashMap> getCxXgsByCzr() {
        return xgsService.getXgsByCzr(request, this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId());
    }

    @RequestMapping("/czrry")
    @ResponseBody
    public List<HashMap> getRyxxByCzrGs() {
        return ryService.getRyxxByCzr(request, this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId());
    }

    @RequestMapping("/pqdlfs")
    @ResponseBody
    public List<HashMap> pqdlfs() {
        return dicService.getDicListByFl("派遣代理");
    }

    @RequestMapping("/sbzh")
    @ResponseBody
    public List<HashMap> sbzh() {
        return zhService.getZhListByType("01");
    }

    @RequestMapping("/gjjzh")
    @ResponseBody
    public List<HashMap> gjjzh() {
        return zhService.getZhListByType("02");
    }

    @RequestMapping("/sbjnd")
    @ResponseBody
    public List<HashMap> sbjnd() {
        return dicService.getDicListByFl("社保缴纳地");
    }

    @RequestMapping("/gjjjnd")
    @ResponseBody
    public List<HashMap> gjjjnd() {
        return dicService.getDicListByFl("公积金缴纳地");
    }

    @RequestMapping("/user")
    @ResponseBody
    public List<HashMap> user() {
        //修改为获取所有有效用户
        //return userService.getYxUserList(this.getSubject().hasRole("业务经理")?"":this.getSessionUser().getUserId());
        return userService.getYxUserList("");
    }
    
    @RequestMapping("/zjlx")
    @ResponseBody
    public List<HashMap> getZjlx() {
        return dicService.getDicListByFl("证件类型");
    }
}
